package com.yanqu.road.server.manger.activity.starlight;

import com.yanqu.road.entity.activity.ActivityInfo;
import com.yanqu.road.entity.enums.eActivityType;
import com.yanqu.road.server.TempMgr;
import com.yanqu.road.server.gameplayer.GamePlayer;
import com.yanqu.road.server.gameplayer.module.activity.starlight.StarLightModule;
import com.yanqu.road.server.manger.activity.NormalActivityMgr;
import com.yanqu.road.server.manger.player.GamePlayerMgr;

import java.util.List;

/**
 * @Author : Cxp
 * @Time : 2024-11-11
 * @Description : 星星点灯-Mgr
 */

public class StarLightMgr extends TempMgr {

    public static ActivityInfo activityInfo;

    @Override
    public boolean init() throws Exception {
        return reload();
    }

    @Override
    public boolean reloadConfig() throws Exception {
        return true;
    }

    @Override
    public boolean reloadData() throws Exception {
        return true;
    }

    @Override
    public boolean stop() {
        return false;
    }

    public static void reloadActivityData() {
        getLogger().info("Reload start light activity start!");

        List<ActivityInfo> openActivityInfoList =
                NormalActivityMgr.getOpenActivityInfoList(eActivityType.StarLight.getValue()); // 加载开放的活动
        if (openActivityInfoList.isEmpty()) {
            getLogger().info("No start light activity in show time!");
            return;
        }
        activityInfo = openActivityInfoList.get(0);

        for (GamePlayer player : GamePlayerMgr.getAllOnlinePlayer()) {
            player.getModule(StarLightModule.class).activityReload();
        }

        getLogger().info("Reload start light activity finish!");
    }

    /**
     * getActivityInfo
     *
     * @return ActivityInfo
     */
    public static ActivityInfo getActivityInfo() {
        return activityInfo;
    }
}
